package com.hrpmar.controller;

import com.hrpmar.controller.vo.Node;
import com.hrpmar.pojo.Department;
import com.hrpmar.service.PermissionService;
import com.hrpmar.utils.Log;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by asus on 2017/11/3.
 */
@RestController
@RequestMapping("/sys/permission")
public class PermissionController {

    private String msg;

    @Resource
    private PermissionService permissionService;

    @RequestMapping("/getTree")
    public List<Node> getTree(Integer deId){
        List<Node> list=permissionService.searchNodes4Tree(deId);
        return list;
    }

    @RequestMapping("/grant")
    public String grant(Integer deId,Integer[] ids){
       try{
           permissionService.grant(deId,ids);
           msg="部门授权成功！";
       }catch(Exception ex){
            msg="部门授权失败！";
           Log.logger.error(msg,ex);
       }
       return msg;
    }



}
